package lc.oa.echats;

import com.github.abel533.echarts.Label;
import com.github.abel533.echarts.axis.CategoryAxis;
import com.github.abel533.echarts.axis.ValueAxis;
import com.github.abel533.echarts.code.Trigger;
import com.github.abel533.echarts.data.Data;
import com.github.abel533.echarts.json.GsonOption;
import com.github.abel533.echarts.series.Line;
import com.github.abel533.echarts.series.Pie;
import com.github.abel533.echarts.style.ItemStyle;

public class EchartOptionUtil {
    public static GsonOption getLineChartOptions(Object[] xAxis, Object[] yAxis) {
        GsonOption option = new GsonOption();
        option.title("折线图");
        option.legend("销量");
        option.tooltip().trigger(Trigger.axis);

        ValueAxis valueAxis = new ValueAxis();
        option.yAxis(valueAxis);

        CategoryAxis categorxAxis = new CategoryAxis();
        categorxAxis.axisLine().onZero(false);
        categorxAxis.boundaryGap(true);
        categorxAxis.data(xAxis);
        option.xAxis(categorxAxis);

        Line line = new Line();
        line.smooth(false).name("销量").data(yAxis).itemStyle().normal().lineStyle().shadowColor("rgba(0,0,0,0.4)");
        option.series(line);
        return option;
    }
    public static  GsonOption getPieChartOptions(){
        GsonOption option = new GsonOption();
//        option.title("圆饼图");
//        option.legend("陕西");
//        option.legend("陕西2");
//        option.legend("陕西3");
        option.tooltip().trigger(Trigger.item);

        //样式更改
        ItemStyle dataStyle = new ItemStyle();
        dataStyle.normal().label(new Label().show(false)).labelLine().show(false);

        //货款率
        ItemStyle placeHolderStyle = new ItemStyle();
        placeHolderStyle.normal().color("#85e5c4");
        placeHolderStyle.emphasis().color("#85e5c4");
        ItemStyle placeHolderStyle1 = new ItemStyle();
        placeHolderStyle1.normal().color("#ecfaf6");
        placeHolderStyle1.emphasis().color("#ecfaf6");

        //利润完成比
        ItemStyle placeHolderStyle2 = new ItemStyle();
        placeHolderStyle2.normal().color("#FFAF90");
        placeHolderStyle2.emphasis().color("#FFAF90");
        ItemStyle placeHolderStyle3 = new ItemStyle();
        placeHolderStyle3.normal().color("#fdf3ef");
        placeHolderStyle3.emphasis().color("#fdf3ef");

        //利润完成比
        ItemStyle placeHolderStyle4 = new ItemStyle();
        placeHolderStyle4.normal().color("#b8affb");
        placeHolderStyle4.emphasis().color("#b8affb");
        ItemStyle placeHolderStyle5 = new ItemStyle();
        placeHolderStyle5.normal().color("#f2f0ff");
        placeHolderStyle5.emphasis().color("#f2f0ff");

        Pie pie2 = new Pie();
        pie2.radius(70,85).itemStyle(dataStyle).data(new Data("", 68).itemStyle(placeHolderStyle2),new Data("", 32).itemStyle(placeHolderStyle3));
        Pie pie = new Pie();
        pie.radius(85,100).itemStyle(dataStyle).data(new Data("", 58).itemStyle(placeHolderStyle),new Data("", 42).itemStyle(placeHolderStyle1));
        Pie pie1 = new Pie();
        pie1.radius(100,115).itemStyle(dataStyle).data(new Data("", 88).itemStyle(placeHolderStyle4),new Data("", 12).itemStyle(placeHolderStyle5));

        option.series(pie,pie1,pie2);
        //        ItemStyle dataStyle = new ItemStyle();
//        dataStyle.normal().label().show(true).formatter("{b}\n({d}%)");
//        Pie pie = new Pie("访问来源");
//        pie.clockWise(false).center("48%", "45%").radius("55", "80")
//                .itemStyle(dataStyle)
//                .data(
//                        new Data("直接访问",335),
//                        new Data("邮件营销",310),
//                        new Data("联盟广告",274),
//                        new Data("视频广告",235),
//                        new Data("搜索引擎",400)
//                );
//        option.series(pie);
        return option;
    }
}
